package com_5;

import java.util.function.Function;

public class FunctionDemo {//定义一个测试类
    public static void main(String[] args) {//main方法入口
//        getString("666", s -> Integer.parseInt(s));//
        String s1="诸葛亮,46";
//     getString(s1,ss->ss.split(",")[1],ss->Integer.parseInt(ss) ,i->i+30);
        getString(s1,ss->ss.split(",")[1],ss->Integer.parseInt(ss),i->i+70);
        getString(s1, new Function<String, String>() {
            @Override
            public String apply(String s) {
                return s.split(",")[1];
            }
        }, new Function<String, Integer>() {
            @Override
            public Integer apply(String s) {
                return Integer.parseInt(s);
            }
        }, new Function<Integer, Integer>() {
            @Override
            public Integer apply(Integer i) {
                return i+70;
            }
        });
    }
    public static void getString(String s, Function<String, String> fun1, Function<String, Integer> fun2,Function<Integer, Integer> fun3){
        Integer apply = fun1.andThen(fun2).andThen(fun3).apply(s);
        System.out.println(apply);

    }
//    public static void getString(String s, Function<String, Integer> fun1) {//
//        Integer apply = fun1.apply(s);//
//        System.out.println(apply);
//    }
}
